let DataStore = {
  params: {},
  singleValues: {},
  waterstyles: {},
  waterbrands: [],
  price: [],
  userprice: [],
  disprice: [],
  getParam (key) {
    return this.params[key]
  },
  getSingleValue (key) {
    return this.singleValues[key]
  },
  getWaterstyle (key) {
    return this.waterbrands.key
  },
  getWaterbrand () {
    return this.waterbrands
  },
  getDis (object) {
    if (!object.f_waterproperties) {
      return
    }
    let result = []
    // 做筛选
    this.disprice.forEach((item) => {
      if (object.f_waterproperties === item.f_waterproperties) {
        let value = {
          label: '',
          value: ''
        }
        value.label = `${item.f_discounts_type}`
        value.value = item
        result.push(value)
      }
    })
    // 数组去重
    let hash = {}
    result = result.reduce((item, next) => {
      hash[next.label] ? '' : hash[next.label] = true && item.push(next)
      return item
    }, [])
    return Array.from(new Set(result))
  },
  getAllDis () {
    let result = []
    // 做筛选
    this.disprice.forEach((item) => {
      let value = {
        label: '',
        value: ''
      }
      value.label = `${item.f_discounts_type}`
      value.value = `${item.f_discounts_type}`
      result.push(value)
    })
    // 数组去重
    let hash = {}
    result = result.reduce((item, next) => {
      hash[next.label] ? '' : hash[next.label] = true && item.push(next)
      return item
    }, [])
    return Array.from(new Set(result))
  },
  getUserPrice (object) {
    if (!object.f_user_id) {
      return
    }
    let result = []
    // 做筛选
    this.userprice.forEach((item) => {
      if (object.f_user_id === item.f_user_id) {
        let value = {
          label: '',
          value: ''
        }
        value.label = `${item.f_price_name}`
        value.value = item
        result.push(value)
      }
    })
    // 数组去重
    let hash = {}
    result = result.reduce((item, next) => {
      hash[next.label] ? '' : hash[next.label] = true && item.push(next)
      return item
    }, [])
    return Array.from(new Set(result))
  },
  getPrice (object) {
    if (!object.f_user_type || !object.f_waterproperties) {
      return
    }
    let result = []
    // 做筛选
    this.price.forEach((item) => {
      if (object.f_user_type === item.f_user_type && object.f_waterproperties === item.f_waterproperties) {
        let value = {
          label: '',
          value: ''
        }
        value.label = `${item.f_price_name}`
        value.value = item
        result.push(value)
      }
    })
    // 数组去重
    let hash = {}
    result = result.reduce((item, next) => {
      hash[next.label] ? '' : hash[next.label] = true && item.push(next)
      return item
    }, [])
    return Array.from(new Set(result))
  },
  getAllPrice () {
    let result = []
    // 做筛选
    this.price.forEach((item) => {
      let value = {
        label: '',
        value: ''
      }
      value.label = `${item.f_price_name}`
      value.value = `${item.f_price_name}`
      result.push(value)
    })
    // 数组去重
    let hash = {}
    result = result.reduce((item, next) => {
      hash[next.label] ? '' : hash[next.label] = true && item.push(next)
      return item
    }, [])
    return Array.from(new Set(result))
  }
}

export default DataStore
